<template>
  <div class="tab-content-wrap">
    <u-page-config
      :getList="getList"
      :tableData="tableData"
      :tableColumn="tableColumn"
      :total="total"
      :loading="loading"
      :showFilter="false"
      :showTool="false"
      @addRow="addRow"
    >

      <template #maintenanceType="{row, item}">
        {{ getDictLabel(maintenanceTypeOptions, row.maintenanceType) }}
      </template>
    </u-page-config>

    <add-fix-records-dialog
      v-model="addRecordsDialogVisible"
      @getList="getList"
    />

  </div>
</template>

<script>
import UPageConfig from '@/components/uPageConfig/index';
import table from '@/mixin/uTable';
import {getMaitenance} from '@/api/operationAndMonitoring/fixRecords';
import AddFixRecordsDialog from '@/views/operationAndMonitoring/fixRecords/components/addFixRecordsDialog'

export default {
  name: "modelInfo",
  mixins: [table],
  components: {UPageConfig,AddFixRecordsDialog},
  props: {
    // 模块列表
    deviceId: {
      type: String,
      default: ''
    },
  },
  data(){
    return{
      maintenanceTypeOptions: [
        {label: '更换', value: 1},
        {label: '维修', value: 2},
      ],
      tableData: [],
      tableColumn: [
        // {label: "设备ID", prop: "modelName"},
        // {label: "设备名称", prop: "modelName"},
        // {label: "外设驱动设备器", prop: "modelName"},
        {label: "维修模块", prop: "moduleName"},
        {label: "旧模块型号", prop: "oldModule"},
        {label: "新模块型号", prop: "newModule"},
        {label: "维修方式", prop: "maintenanceType", type: 'slot', slot: 'maintenanceType'},
        {label: "维修人", prop: "operationUserName"},
        {label: "维修时间", prop: "createTime", type: "time"},
        {label: "备注", prop: "remark"},
        {label: "关联工单", prop: "workOrderId"},
      ],
      actionBtn: [
        {
          type: 'primary',
          text: '新增维修记录',
          icon: 'el-icon-plus',
          emit: 'addRow',
          permissions: 'operationAndMonitoring:workOrder:add'
        }
      ],
      addRecordsDialogVisible: false,
    }
  },
  methods:{
    // 添加
    addRow() {
      this.addRecordsDialogVisible = true;
    },
    /** 查询工单列表 */
    getList() {
      this.getInit(getMaitenance, {
        deviceId: this.deviceId
      })
    },
  }
}
</script>
